package com.orderSystem;

import com.databaseManager.Patient;

import java.awt.*;
import java.util.*;

/*队列单例*/
public class QueueInstance {

    public Queue<Patient> getNormalProQueue() {
        return normalProQueue;
    }

    public Queue<Patient> getNormalDepQueue() {
        return normalDepQueue;
    }

    private Queue<Patient> normalProQueue = new LinkedList<Patient>();          //1
    private Queue<Patient> normalDepQueue = new LinkedList<Patient>();          //2
    private ArrayList<Patient> depList = new ArrayList<Patient>();        //3
    private ArrayList<Patient> proList = new ArrayList<Patient>();        //4
    private Queue<Patient> priorityProQueue = new LinkedList<Patient>();        //5
    private Queue<Patient> priorityDepQueue = new LinkedList<Patient>();        //6
    private Map<Patient,String> name_priorityDepQueue = new HashMap<Patient,String>(); //7
    private Map<Patient,String> name_priorityProQueue = new HashMap<Patient,String>(); //8
    private Map<Patient,String> name_normalDepQueue = new HashMap<Patient,String>();  //9
    private Map<Patient,String> name_normalProQueue = new HashMap<Patient,String>();  //10

    public Map<Patient, String> getName_priorityDepQueue() {
        return name_priorityDepQueue;
    }

    public Map<Patient, String> getName_priorityProQueue() {
        return name_priorityProQueue;
    }

    public Map<Patient, String> getName_normalDepQueue() {
        return name_normalDepQueue;
    }

    public Map<Patient, String> getName_normalProQueue() {
        return name_normalProQueue;
    }



    public Queue<Patient> getPriorityProQueue() {
        return priorityProQueue;
    }

    public Queue<Patient> getPriorityDepQueue() {
        return priorityDepQueue;
    }



    public ArrayList<Patient> getDepList() {
        return depList;
    }

    public ArrayList<Patient> getProList() {
        return proList;
    }

    public void setNormalProQueue(Queue<Patient> normalProQueue) {
        this.normalProQueue = normalProQueue;
    }

    public void setNormalDepQueue(Queue<Patient> normalDepQueue) {
        this.normalDepQueue = normalDepQueue;
    }


    public void inMap(int i,Patient patient,String sid) {
        switch (i) {
            case 7:
                this.name_priorityDepQueue.put(patient, sid);
            case 8:
                this.name_priorityProQueue.put(patient, sid);
            case 9:
                this.name_normalDepQueue.put(patient, sid);
            case 10:
                this.name_normalProQueue.put(patient, sid);
        }

    }

    public Patient outQueue(int i){
        switch (i) {
            case 1:
                return this.normalProQueue.poll();
            case 2:
                return this.normalDepQueue.poll();
            case 5:
                return this.priorityProQueue.poll();
            case 6:
                return this.priorityDepQueue.poll();
        }
        return null;
    }
    public void inQueue(int i, Patient patient){
        switch (i) {
            case 1:
                this.normalProQueue.offer(patient);
            case 2:
                this.normalDepQueue.offer(patient);
            case 3:
                this.depList.add(patient);
            case 4:
                this.proList.add(patient);
            case 5:
                this.priorityProQueue.offer(patient);
            case 6:
                this.priorityDepQueue.offer(patient);
        }
    }
    public void outList(int i,Patient patient){
        switch (i){
            case 3:
                this.depList.remove(patient);
            case 4:
                this.proList.remove(patient);
        }
    }

    public static void setInstance(QueueInstance instance) {
        QueueInstance.instance = instance;
    }
    private static QueueInstance instance;

    private QueueInstance() {}

    public static synchronized QueueInstance getInstance() {
	if (instance == null)
	    instance = new QueueInstance();
	return instance;
    }
}
